<template>
  <!-- 已录入 -->
  <div class="box clearfix">
    <section class="section_wrap">
      <div class="title_sub prduct_bod_r">产品说明：</div>
      <ProductDescriptionToo></ProductDescriptionToo>
    </section>
    <section class="section_wrap">
      <div class="title_sub infro_bod_l">信息查看：</div>
      <div class="state">状态：{{ orderStatusName }}</div>
      <InformationsViewer
        :orderNumber="orderNumber"
        :orderStatus="orderStatus"
      ></InformationsViewer>
    </section>
    <section class="section_wrap">
      <div class="title_sub upload_bod_l">附件管理：</div>
      <Upload ref="Uploade" :isNew="isNew"></Upload>
    </section>
    <section class="section_wrap" v-if="orderStatus == 0">
      <div>
        <el-button type="primary" class="primaryButton" @click="primaryButton"
          >提交审批</el-button
        >
      </div>
    </section>
  </div>
</template>

<script>
import {
  putOrderCommit,
  getProductUrl,
  getOrderOne
} from "../../../src/assets/js/api";
import ProductDescriptionToo from "../../components/business/ProductDescriptionToo";
import InformationsViewer from "../../components/business/InformationsViewer";
import Upload from "../../components/business/Upload";
export default {
  name: "HasBeenRecordedList",
  components: {
    ProductDescriptionToo,
    InformationsViewer,
    Upload
  },
  data() {
    return {
      showButton: true,
      isNew: false,
      orderNumber: "",
      markUpdate: "",
      golbalPermissions: [],
      ProductUrl: "",
      orderStatusName: "",
      orderStatus: ""
    };
  },
  created() {
    this.getOrderNum();
    this.getOrderOne();
  },
  mounted() {
    // this.getProductUrl();
  },
  methods: {
    // 获取本条信息
    getOrderOne() {
      getOrderOne(this.orderNumber).then(res => {
        this.orderStatusName = res.data.orderStatusName;
        this.orderStatus = res.data.orderStatus;
      });
    },
    //根据orderNumber判断跳转的产品路径
    getProductUrl() {
      getProductUrl({ orderNumber: this.orderNumber }).then(res => {
        this.ProductUrl = res.data.productUrl;
      });
    },
    //判断获取orderNumber
    getOrderNum() {
      let orderNumber = this.$route.query.orderNumber;
      if (orderNumber) {
        this.orderNumber = orderNumber;
      } else {
        this.orderNumber = sessionStorage.getItem("orderNumber");
      }
    },
    //提交审批按钮
    primaryButton() {
      //验证审批的身份证图片
      let uploadImg = this.$refs.Uploade.fileList;
      if (!uploadImg.length >= 1) {
        this.$message({
          message: "请上传身份证件照",
          type: "error"
        });
      } else {
        putOrderCommit(this.orderNumber).then(res => {
          if (res.code == 200) {
            this.$message({
              message: res.message,
              type: "success"
            });
             this.$router.go(-1);
            // this.getOrderOne();
          } else {
            this.$message({
              message: res.message,
              type: "error"
            });
          }
          // this.$router.replace({ path: this.ProductUrl });
        });
      }
    }
  }
};
</script>

<style scoped type="less">
.text {
  font-size: 20px;
  font-weight: bold;
  text-align: left;
  margin-top: 20px;
  text-indent: 2em;
}
.state {
  font-size: 22px;
  font-weight: bold;
  float: right;
  margin-top: -20px;
  margin-right: 3%;
}

.uploadStyle {
  width: 97%;
  position: relative;
  margin-top: 20px;
}
.primaryButton {
  width: 180px;
  height: 45px;
  margin-top: 20px;
}
</style>
